package com.one.api.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

//@EnableConfigurationProperties
@RestController
@RequestMapping("/config")
public class ConfigDiscoveryController {
//    @Autowired
//    RestTemplate restTemplate;

    @Value("${ip}")
    private String ip;
    @Value("${port}")
    private String port;

    @RequestMapping("/hi")
    public String hi(@RequestParam(value = "id")String id){
//        return restTemplate.getForObject("http://api-user-0/userconfig/hi?id="+id, String.class);
        return "hi:"+id;
    }

    @RequestMapping("/getProp")
    public Map<String, String> getProp(){
        Map<String, String> map=new HashMap<>();
        map.put("ip", ip);
        map.put("port", port);
        return map;
    }
}
